var vm = new Vue({
    el: '#main',
    data: {
        systemEnquDatas:[],
        versionObj:{
            systemNo:'',
            systemName:'',
            systemChargePop:'',
            systemPhone:'',
            systemPhoneType:'',
            systemUrl:'',
            systemDateUrl:''
        },
        deleteDatas:{},
        pagination: [],
        systemNo:'',
        systemName:'',
        systemChargePop:'',
        nowPage:1,
        rowNum:10,
        allPages:0,
        jumpPage:'',
        listLength:'',
    },
    mounted: function () {
        this.getData();
    },
    methods:{
        //默认查询
        getData(){
            let obj = {
                systemNo:this.systemNo,
                systemName:this.systemName,
                systemChargePop:this.systemChargePop,
                nowPage:this.nowPage,
                rowNum:this.rowNum,
            }
            axios({
                method: "post",
                url: App.envUrl.backtrackUrl+"sysMaintain/querySysMaintain",
                data: obj,
            })
            .then((data) => {
                console.log("查询",data)
                if(data.data.code === '200'){
                    this.systemEnquDatas = data.data.pageCount.datas;
                    this.nowPage = data.data.pageCount.nowPage;
                    this.allPages = data.data.pageCount.allPages;
                    this.pagination = getPagination(this.nowPage,this.allPages);
                    this.listLength = data.data.pageCount.allCount;
                    if(data.data.pageCount.datas && data.data.pageCount.datas.length == 0){
                    	parent.showAlert('抱歉，未查询到符合条件的数据！');
                    }
                }else {
                    parent.showAlert(data.data.msg);
                }
            })
            .catch((err) => {});
        },
        //查询
        check_c(){
            this.getData();
        },
        //重置
        check_r(){
            this.systemNo = '';
            this.systemName = '';
            this.systemChargePop = '';
            this.getData();
        },
        //删除
        deleteBtn:function(){
        	vm.deleteDatas.datas = [];
        	var str ="";
            $("input[name='any']:checked").each(function(){
//                vm.deleteDatas.datas.push($(this).val());
                	str += $(this).val()+","
            });
            vm.deleteDatas.datas = str.substring(0,str.length-1);
            if(str != ""){
            	parent.showConfirm(
            		"提示信息",
            		"确定要删除所选内容吗？",
            		function(){
            			axios({
                            method: "post",
                            url:App.envUrl.backtrackUrl+"sysMaintain/deleteSysMaintain",
                            data: vm.deleteDatas,
                        })
                        .then((data) => {
                        	parent.showAlert(data.data.msg,function(){
                        		window.location.reload();
                        	});
                        })
                        .catch((err) => {});
            		}
            	);
            }
           
        },
        //新增
        addBtn(){
            window.location.href =
            "systemAdd.html";
        },
        allBtn:function(){
            var checkBoxs = $(".anyCheck");
            var checked = $("#allCheck")[0].checked;
            if(checked){
                for(var i=0;i<checkBoxs.length;i++){
                    checkBoxs[i].checked = true;
                }
            } else {
                for(var i=0;i<checkBoxs.length;i++){
                    checkBoxs[i].checked = false;
                }
            }
        },
        //维护
        gotoPage(val){
            console.log(val)
            sessionStorage.setItem('obj',JSON.stringify(val))
            window.location.href =
            "systemMaintenance.html";
        },
        //页面节点配置
        editPage(val){
            sessionStorage.setItem('obj',JSON.stringify(val))
            window.location.href =
            "sysEditPage.html";
        },
        //分页
        selectPage(page){
            this.nowPage = page;
            this.getData();
            var checkBoxs = $(".anyCheck");
        	for(var i=0;i<checkBoxs.length;i++){
                checkBoxs[i].checked = false;
            }
        },
        offsetPage(offset){
            this.nowPage = this.nowPage + offset;
            this.getData();
        },
        skipPage() {
        	this.nowPage = document.getElementById('page-num').value;
        	document.getElementById('page-num').value = '';
        	this.getData();
        	var checkBoxs = $(".anyCheck");
        	for(var i=0;i<checkBoxs.length;i++){
                checkBoxs[i].checked = false;
            }
        },
        rowNumChange(val){
            this.rowNum = Number(val)
            this.getData()
            console.log(val,'11111111111')
        }
    }, 
});